home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / univspl / big_time.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-27  |  23.2 KB  |  638 lines

  1. #define    VXWORKS    0        /* 1 for VxWorks, 0 for MacOS                            */
  2. #define    MCOS     0        /* 1 for Mercury MCOS, 0 for MacOS                       */
  3. #define  TWIN 1        /* 1 for MacOS, 0 for Windows */
  4. #define    BIG    0            /* 1 for rotating timing buffers, 0 for static addresses */
  5. #define    STATIC    0        /* 1 for static memory allocation, 0 for run-time malloc */
  6. #define NMAX    16384    /* Largest test vector size allowed                      */
  7. #if BIG
  8. #define    STATIC    0        /* BIG => force dynamic memory allocation    */
  9. #endif
  10. #if ((VXWORKS)&&(MCOS))
  11. #define    MCOS    0        /* can't have it both ways                    */
  12. #endif
  13.  
  14. /* USPL Big Wrapper Timer                                                   */
  15. /*                                                                          */
  16. /* Usage:   big_timer [npts]                                                */
  17. /*                                                                          */
  18. /* HISTORY:                                                                 */
  19. /* When         Who                 What                                    */
  20. /* Mar 31 1998    Bill Fincke         Created for Mercury SAL under MCOS      */
  21. /* Nov 19 1998  Bill Fincke         Ported to MacOS, VxWorks for USPL       */
  22. /*                                                                          */
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #if VXWORKS
  28. #include <ticLib.h>
  29. #include <sysLib.h>
  30. #else
  31. #include <time.h>
  32. #endif
  33. #include "uspl.h"
  34.  
  35. /* below line added 12/10/98 RDK */
  36. void timer(char *name, float ptime2, float ptime3, void (*funct)(), long npt);
  37.  
  38.     double align;
  39. #if STATIC
  40.     float b1[NMAX],b2[NMAX],b3[NMAX];
  41.     float cwts[NMAX*2];
  42.     long ib[8192];
  43. #else
  44.     unsigned long alignment;
  45.     float *b1, *b2, *b3;
  46.     float *cwts;
  47.     long *ib;
  48. #if BIG
  49.     float *S[32],*D[32];
  50. #endif
  51. #endif
  52.     float *cs1, *cs2, *cso;
  53.     float rs1, rs2, rs3, rs4, rso;
  54.     double *dv1, *dvo;
  55.     float *rv, *rv1, *rv2, *rv3, *rv4, *rvo, *rvio, *rvt;
  56.     float *cv1, *cv2, *cv3, *cvo, *cvio, *cvt;
  57.     long *iv1, *iv2, *ivo;
  58.     short int *sv1, *svo;
  59.     char *bv1, *bvo;
  60.     long inc=1, inc1=1, inc2=1, inc3=1, inc4=1, inco=1, incio=1;
  61.     long flg=1, flg1=1, flg2=1;
  62.     long no = 1024, ndf = 1;
  63.     float z=0, a=1.0, b=2.0, c=3, d=1, rm1=-1, rp1=1;
  64.     long i1=1,i2=2, idx;
  65. int n1=1, n2=2, n8=8, n16=16, n32=32, n64=64, n128=128, n256=256, n512=512;
  66. int n1k=1024, n2k=2048, n4k=4096, n8k=8192, n16k=16384;
  67. int n100=100, n300=300;
  68. int npts=1024;
  69.  
  70. /*-- define macros to initialize inputs ---*/
  71. #if BIG
  72. #define INIT_INPUTS(X)                        \
  73. for(j=0;j<8;j++)                            \
  74.    for(i=0; i<NMAX; i++)S[j][i] = (X);
  75. #else
  76. #define INIT_INPUTS(X)                        \
  77. for(i=0; i<NMAX; i++)b1[i]=(X);
  78. #endif
  79.  
  80. #if BIG
  81. #define INIT_DOUBLE(X)                        \
  82. for(j=0;j<8;j++)                            \
  83.    {                                        \
  84.     dv1=(double*)S[j];                        \
  85.     for(i=0; i<npts; i++)dv1[i] = (X);        \
  86.     }
  87. #else
  88. #define INIT_DOUBLE(X)                        \
  89. for(i=0; i<npts; i++)dv1[i]=(X);
  90. #endif
  91. /* changed to void_big_timre_funcs.h 12/10/98 RDK */
  92. #include "void_big_timer_funcs.h"
  93.  
  94. main (argc, argv)
  95. int argc;
  96. char *argv[];
  97. {
  98.         static char sccsid[] = "@(#)timer.c    1.60\t7/21/93 USPL";
  99. long i,j;
  100.  
  101. #if ((!VXWORKS)&&(!MCOS) && (!TWIN))
  102. /* get command line arguments from CodeWarrior */
  103.     argc = ccommand(&argv);
  104. #endif
  105.  
  106. /*    Get argument (test vector size) if any    */
  107.  
  108. if (argc>1)
  109.     {
  110.     i = strtol(argv[1],0,0);
  111.     if ((i>16) && (i<=NMAX)) npts = i;
  112.     }
  113. else
  114.     npts = n1k;        /* default is 1k    */
  115.  
  116. #if !STATIC
  117. i = NMAX*2;                /* nominal size of b1    */
  118. j = 512*512;            /* room required for mxmov(512x512)    */
  119. i = (i < j) ? j : i;    /* make sure we have enough room for mxmov! */
  120. printf("malloc %d floats for b1\n",i);
  121. b1 = (float *)malloc(i*sizeof(float));
  122. b2 = (float *)malloc(NMAX*2*sizeof(float));
  123. b3 = (float *)malloc(NMAX*2*sizeof(float));
  124. cwts = (float *)malloc(NMAX*2*sizeof(float));
  125. ib = (long *)malloc(8192*sizeof(long));
  126. printf ("Address of b1=%X b2=%X b3=%X cwts=%X ib=%X\n",b1,b2,b3,cwts,ib);
  127. if ((long)b1%4!=0 || (long)b2%4!=0 || (long)b3%4!=0 || (long)cwts%4!=0 || (long)ib%4!=0)
  128. {
  129.    printf("Adress not 4 byte aligned. Exiting.\n");
  130.    exit(-1);
  131. }
  132.    
  133. if ((b1==(float *)0) || (b2==(float *)0) || (b3==(float *)0) ||
  134.     (cwts==(float *)0) || (ib==(long *)0) )
  135.    { printf("can't allocate buffer space - increase heap at runtime!\n"); exit(0);}
  136. #if BIG
  137. printf("\nrunning BIG version\n");
  138. i = 32*(NMAX/2);        /* nominal size of S[i]    */
  139. j = 512*512;            /* room required for mxmov(512x512)    */
  140. if (i<j)                /* make sure we have enough room for mxmov! */
  141.    { printf("NMAX = %d not big enough for 512x512 mxmov!\n",NMAX); exit(0);}
  142. S[0] = S[8] = S[16] = S[24] = (float *)malloc(32*(NMAX/2)*sizeof(float));
  143. if ((S[0]==(float *)0) )
  144.         { printf("can't allocate big S buffer space - increase heap at runtime!\n"); exit(0);}
  145. for (i=1; i<8; i++)
  146.     {
  147.     S[i] = S[i-1] + NMAX*2;
  148.     S[i+8] = S[i+16] = S[i+24] = S[i] ;
  149. /* printf("S[%d],S[%d],S[%d],S[%d] = 0x%08x\n",i,i+8,i+16,i+24,S[i]); */
  150.     }
  151. D[0] = D[8] = D[16] = D[24] = (float *)malloc(32*(NMAX/2)*sizeof(float));
  152. if ((D[0]==(float *)0) )
  153.         { printf("can't allocate big D buffer space - increase heap at runtime!\n"); exit(0);}
  154. for (i=1; i<8; i++)
  155.     {
  156.     D[i] = D[i-1] + NMAX*2;
  157.     D[i+8] = D[i+16] = D[i+24] = D[i] ;
  158. /* printf("D[%d],D[%d],D[%d],D[%d] = 0x%08x\n",i,i+8,i+16,i+24,D[i]); */
  159.     }
  160. #else
  161. printf("\nrunning SMALL version\n");
  162. #endif
  163. #endif
  164.  
  165. rv1 = rv2 = rv3 = rv4 = rvio = b1;
  166. rvo = b2;
  167. rvt = b3;
  168. cv1 = cv2 = cv3 = cvio = b1;
  169. cvo = b2;
  170. cvt = b3;
  171. cs1 = cs2 = b1;
  172. cso = b2;
  173. iv1 = iv2 = (long*)b1;
  174. ivo = (long*)b2;
  175. sv1 = (short int *)b1;
  176. svo = (short int *)b2;
  177. bv1 = bvo = (char*)b1;
  178. bvo = (char*)b2;
  179. dv1 = (double*)b1;
  180. dvo = (double*)b2;
  181. printf("\n\n");
  182. printf("           CSPI     CSPI     Sigma    Sigma   Sigma    Sigma     Sigma\n");
  183. printf("           SC 2     SC 3     \n");
  184. printf("           Pub.     Pub.     Meas.    Ovhd.    Time   vs SC 2   vs SC 3\n");
  185. printf("Funct     (ms/1K)  (ms/1K)  (ms/1K) (us/call) (ns/pt)  (%%)       (%%)\n"); 
  186. a = 1.0;
  187. printf("\n \n  USPL routines (%d-pt vectors): \n",npts);
  188.  
  189.  
  190. INIT_INPUTS (.00001*i)
  191. #define NOSKIP 1
  192. #if NOSKIP
  193. fftwts(cwts, n16, n16);
  194. timer("CFFTF_16  ", .030, .032,*cfftf_time, n16);
  195. fftwts(cwts, n64, n64);
  196. timer("CFFTF_64  ", .080, .067,*cfftf_time, n64);
  197. fftwts(cwts, n128, n128);
  198. timer("CFFTF_128 ", .135, .113,*cfftf_time, n128);
  199. fftwts(cwts, n256, n256);
  200. timer("CFFTF_256 ", .229, .191,*cfftf_time, n256);
  201. fftwts(cwts, n512, n512);
  202. timer("CFFTF_512 ", .39 , .32 ,*cfftf_time, n512);
  203. fftwts(cwts, n1k, n1k);
  204. timer("CFFTF_1K  ", .80 , .650,*cfftf_time, n1k);
  205. fftwts(cwts, n2k, n2k);
  206. timer("CFFTF_2K  ", 2.9 ,2.300,*cfftf_time,  n2k);
  207. fftwts(cwts, n4k, n4k);
  208. timer("CFFTF_4K  ", 5.6 ,4.500,*cfftf_time,  n4k);
  209. fftwts(cwts, n8k, n8k);
  210. timer("CFFTF_8K  ", 12. ,9.500,*cfftf_time,  n8k);
  211. timer("CFFTSC_1K ", .12 , .011,*cfftsc_time, n1k);
  212. fftwts(cwts, n64, n64);
  213. timer("RFFTF_64  ", .029,  .023,*rfftf_time, n64);
  214. fftwts(cwts, n128, n128);
  215. timer("RFFTF_128 ", .058,  .046,*rfftf_time, n128);
  216. fftwts(cwts, n256, n256);
  217. timer("RFFTF_256 ", .115,  .092,*rfftf_time, n256);
  218. fftwts(cwts, n512, n512);
  219. timer("RFFTF_512 ", .23 ,  .18,*rfftf_time, n512);
  220. fftwts(cwts, n1k, n1k);
  221. timer("RFFTF_1K  ", .49 ,  .39,*rfftf_time, n1k);
  222. fftwts(cwts, n2k, n2k);
  223. timer("RFFTF_2K  ", .95 ,  .81,*rfftf_time,  n2k);
  224. fftwts(cwts, n4k, n4k);
  225. timer("RFFTF_4K  ", 3.9 ,  3.0,*rfftf_time,  n4k);
  226. fftwts(cwts, n8k, n8k);
  227. timer("RFFTF_8K  ", 7.4 ,  5.8,*rfftf_time,  n8k);
  228. timer("RFFTSC_1K ", .064, .057,*rfftsc_time, n1k);
  229. #endif    /* NOSKIP */
  230. fftwts(cwts, 2*npts, 2*npts);
  231. #if NOSKIP
  232. timer("ACORF     ", 2.3 , 1.8 ,*acorf_time, npts);
  233. INIT_INPUTS (.00001*i)
  234. if (npts <= 2048)
  235.     timer("ACORT     ", 27. ,22.0 ,*acort_time, npts);
  236. else
  237.     timer("ACORT 2K  ", 27. ,22.0 ,*acort_time, n2k);
  238. timer("ASPEC     ", .12 , .10 ,*aspec_time, npts);
  239. /* fftwts(cwts, npts, npts); */
  240. timer("BLKMAN    ", 1.7 , 1.3 ,*blkman_time, npts);
  241. timer("CCDOTP    ", .18 , 0.14,*ccdotp_time, npts);
  242. /* removed due to excesive delay 12/10/98 RDK
  243. timer("CCORF     ", 3.4 , 2.7, *ccorf_time, npts);
  244. */
  245. INIT_INPUTS (.00001*i)
  246. if (npts <= 2048)
  247.     timer("CCORT     ", 27. , 22., *ccort_time, npts);
  248. else
  249.     timer("CCORT 2K  ", 27. , 22., *ccort_time, n2k);
  250. timer("CDOTPR    ", .18 , .14, *cdotpr_time, npts);
  251. timer("CONVD_32  ", .88 , .70, *convd_time, npts);
  252. timer("CPOW      ", .15 , .12, *cpow_time, npts);
  253. INIT_INPUTS (i+1)    /* don't divide 0/0!! */
  254. timer("CRVDIV    ", .34 , .26, *crvdiv_time, npts);
  255. timer("CRVMUL    ", .28 , .22, *crvmul_time, npts);
  256. timer("CSPEC     ", .29 , .24, *cspec_time, npts);
  257. timer("CVABS     ", .35 , .29, *cvabs_time, npts);
  258. timer("CVADD     ", .19 , .15, *cvadd_time, npts);
  259. timer("CVCML     ", .23 , .18, *cvcml_time, npts);
  260. timer("CVCMLA    ", .30 , .24, *cvcmla_time, npts); 
  261. timer("CVCOMB    ", .19 , .15, *cvcomb_time, npts);
  262. timer("CVCONJ    ", .12 , .10, *cvconj_time, npts); 
  263. timer("CVCSML    ", .18 , .14, *cvcsml_time, npts); 
  264. timer("CVDIV     ", .47 , .37, *cvdiv_time, npts);
  265. timer("CVEXP     ", 1.1 , .90, *cvexp_time, npts);
  266. timer("CVFILL    ", .15 , .12, *cvfill_time, npts); 
  267. timer("CVMA      ", .30 , .24, *cvma_time, npts);
  268. timer("CVMAGS    ", .09 , .07, *cvmags_time, npts);
  269. timer("CVMEXP    ", 1.3 , .97, *cvmexp_time, npts);
  270. timer("CVMGSA    ", .13 , .10, *cvmgsa_time, npts);
  271. timer("CVMUL     ", .23 , .18, *cvmul_time, npts);
  272. timer("CVMLA     ", .30 , .24, *cvmla_time, npts);
  273. timer("CVMOV     ", .12 , .10, *cvmov_time, npts); 
  274. timer("CVMUL     ", .23 , .18, *cvmul_time, npts);
  275. timer("CVNEG     ", .12 , .10, *cvneg_time, npts); 
  276. timer("CVPHAS    ", 1.0 , .83, *cvphas_time, npts);
  277. timer("CVRCIP    ", .47 , .38, *cvrcip_time, npts);
  278. timer("CVREAL    ", .20 , .16, *cvreal_time, npts); 
  279. timer("CVSMA     ", .24 , .20, *cvsma_time, npts);
  280. timer("CVSMUL    ", .12 , .10, *cvsmul_time, npts);
  281. timer("CVSQRT    ", 1.3 , 1.1, *cvsqrt_time, npts);
  282. timer("CVSUB     ", .19 , .15, *cvsub_time, npts);
  283. INIT_INPUTS (.00001*i)
  284. timer("DEQ22     ", .24 , .20, *deq22_time, npts);
  285. timer("DOTPR     ", .07 , .05, *dotpr_time, npts); 
  286. /* fftwts(cwts, npts, npts); */
  287. timer("ENVEL     ", 1.7 , 1.3, *envel_time, npts);
  288. timer("FIX4      ", .12 , .09, *fix4_time, npts);
  289. timer("FIX2N     ", .19 , .15, *fix2n_time, npts);
  290. timer("FIX4N     ", .12 , .09, *fix4n_time, npts);
  291. timer("FIXBN     ", .12 , .09, *fixbn_time, npts);
  292. timer("FLT2      ", .14 , .11, *flt2_time, npts);
  293. timer("FLT2IQ    ", .56 , .44, *flt2iq_time, npts);
  294. timer("FLT4      ", .12 , .10, *flt4_time, npts);
  295. timer("FLTB      ", .15 , .12, *fltb_time, npts);
  296. timer("FLTBU     ", .11 , .088, *fltbu_time, npts); 
  297. timer("FXSL2N    ", .33 , .26, *fxsl2n_time, npts);
  298. timer("FXSL4N    ", .25 , .20, *fxsl4n_time, npts);
  299. timer("FXSLBN    ", .32 , .25, *fxslbn_time, npts);
  300. timer("GCOSF     ", .47 , .37, *gcosf_time, npts);
  301. cs1[0]=0.70710671; cs1[1]=0.70710671;
  302. cs2[0]=1.0; cs2[1]=0.0;
  303. timer("GCEXP fast", .054 , .043, *gcexp_time, npts);
  304. cs1[0]=0.92387952; cs1[1]=0.38268344;
  305. timer("GCEXP slow", .108 , .086, *gcexp_time, npts);
  306. fftwts(cwts, npts, npts);
  307. timer("HAMM      ", .95 , .72, *hamm_time, npts);
  308. timer("HANN      ", .95 , .72, *hann_time, npts);
  309. timer("HLBRT     ", 1.2 , .93, *hlbrt_time, npts);
  310. timer("LVEQ      ", .20 , .16, *lveq_time, npts);
  311. timer("LVGE      ", .20 , .16, *lvge_time, npts);
  312. timer("LVGT      ", .20 , .16, *lvgt_time, npts);
  313. timer("LVLE      ", .20 , .16, *lvle_time, npts);
  314. timer("LVLT      ", .20 , .16, *lvlt_time, npts);
  315. timer("LVNE      ", .20 , .16, *lvne_time, npts);
  316. timer("LVNOT     ", .17 , .13, *lvnot_time, npts);
  317. timer("MAXMGV    ", .17 , .14, *maxmgv_time, npts);
  318. timer("MAXV      ", .14 , .10, *maxv_time, npts);
  319. timer("MEAMGV    ", .097 ,.080,*meamgv_time, npts); 
  320. timer("MEANV     ", .042 ,.033,*meanv_time, npts); 
  321. timer("MEASQV    ", .070 ,.056,*measqv_time, npts); 
  322. timer("MINMGV    ", .17  ,.14, *minmgv_time, npts);
  323. timer("MINV      ", .14  ,.11, *minv_time, npts);
  324. #endif    /* NOSKIP */
  325. timer("MVESSQ    ", .10  ,.080,*mvessq_time, npts);
  326. INIT_INPUTS (.00001*i)
  327. #ifdef MATRIX
  328. timer("MXMLA_128 ", 59.  , 47.,*mxmla_time, npts); 
  329. timer("MXMLS_128 ", 59.  , 47.,*mxmls_time, npts); 
  330. timer("MXMOV_512 ", 55.  , 43.,*mxmov_time, npts);
  331. timer("MXMUL_128 ", 59.  , 47.,*mxmul_time, npts);
  332. #endif
  333.  
  334. #if NOSKIP
  335. timer("POLAR     ", 1.6  ,1.3, *polar_time, npts);
  336. timer("RECT      ", 1.3  ,1.0, *rect_time, npts);
  337. /*
  338. timer("RFZC      ", .09  ,072, *rfzc_time, npts);
  339. */
  340. INIT_INPUTS (0.0)
  341. rs1 = 1000.0;
  342. timer("REQS      ", .087 ,.071,*reqs_time, npts);
  343. rs1 = 1000.0;
  344. timer("RGES      ", .087 ,.071,*rges_time, npts);
  345. rs1 = 1000.0;
  346. timer("RGTS      ", .087 ,.071,*rgts_time, npts);
  347. rs1 = 0.0;
  348. timer("RNES      ", .087 ,.071,*rnes_time, npts);
  349. rs1 = 1000.0;
  350. timer("REQS      ", .087 ,.071,*reqs_time, npts);
  351. rs1 = -1000.0;
  352. timer("RLTS      ", .089 ,.071,*rlts_time, npts);
  353. timer("RMAX      ", .140 ,.11 ,*rmax_time, npts);
  354. timer("RMAXMG    ", .170 , .14,*rmaxmg_time, npts);
  355. INIT_INPUTS (0.0)
  356. b1[0] = -1;
  357. timer("RMIN      ", .140 , .11,*rmin_time, npts);
  358. timer("RMINMG    ", .170 , .14,*rminmg_time, npts);
  359. timer("RMSQV     ", .071 ,.056,*rmsqv_time, npts);
  360. timer("RSVE 32   ", .13 , .10, *rsve_time, npts);
  361. timer("SHPHU     ", .320 , .26,*shphu_time, npts);
  362. timer("SHPHUF    ", .300 , .24,*shphuf_time, npts);
  363. timer("SN2       ", .120 , .10,*sn2_time, npts);
  364. rs1 = 1.0;
  365. INIT_INPUTS (.00001*(i+1))
  366. timer("SVDIV     ", .250 , .19,*svdiv_time, npts);
  367. timer("SVE       ", .040 ,.032,*sve_time, npts);
  368. timer("SVEMG     ", .096 ,.079,*svemg_time, npts);
  369. timer("SVESQ     ", .069 ,.054,*svesq_time, npts);
  370. timer("SVESSQ    ", .097 ,.080,*svessq_time, npts);
  371. timer("TCONV     ", .890 ,.720,*tconv_time, npts);
  372. timer("TRANS     ", .45 , .350,*trans_time, npts);
  373. timer("VAAM      ", .20 , .16, *vaam_time, npts);
  374. timer("VABS      ", .096, .078,*vabs_time, npts);
  375. timer("VACOS     ", 1.50, 1.1, *vacos_time, npts);
  376. timer("VADD      ", .098, .080,*vadd_time, npts);
  377. timer("VAINT     ", .200, .160,*vaint_time, npts);
  378. timer("VAM       ", .13 , .11, *vam_time, npts); 
  379. timer("VANINT    ", .190, .15, *vanint_time, npts);
  380. timer("VASBM     ", .20 , .16, *vasbm_time, npts);
  381. timer("VASIN     ", 1.50, 1.1, *vasin_time, npts);
  382. timer("VASM      ", .098, .081,*vasm_time, npts);
  383. timer("VATAN     ", 1.00, .80, *vatan_time, npts);
  384. timer("VATAN2    ", 1.0 , .81, *vatan2_time, npts);
  385. timer("VATN2F    ", 1.0 , .81, *vatn2f_time, npts);
  386. timer("VAVEXP    ", .100, .082,*vavexp_time, npts);
  387. timer("VAVLIN    ", .100, .082,*vavlin_time, npts);
  388. timer("VCLIP     ", .200, .160,*vclip_time, npts);
  389. timer("VCLR      ", .048, .038,*vclr_time, npts); 
  390. timer("VCMPRS    ", .150, .120,*vcmprs_time, npts); 
  391. timer("VCOS      ", .650, .52, *vcos_time, npts);
  392. timer("VCOSF     ", .460, .37, *vcosf_time, npts);
  393. timer("VDBPWR    ", .800, .64, *vdbpwr_time, npts);
  394. timer("VDIV      ", .28 , .220,*vdiv_time, npts);
  395. #endif    /* NOSKIP */
  396. INIT_DOUBLE (.00001*i)
  397. timer("VDPSP     ", .091, .073,*vdpsp_time, npts);
  398. INIT_INPUTS (.00001*i)
  399. /*
  400. timer("VEQV      ", .26 , .21, *veqv_time, npts);
  401. */
  402. timer("VEUCL2    ", .46 , .36, *veucl2_time, npts);
  403. timer("VEUCL3    ", .54 , .43, *veucl3_time, npts); 
  404. INIT_INPUTS (.001*i)
  405. timer("VEXP      ", .650, .52, *vexp_time, npts);
  406. timer("VEXP2     ", .650, .52, *vexp2_time, npts);
  407. timer("VEXP10    ", .640, .52, *vexp10_time, npts);
  408. timer("VFILL     ", .048, .038,*vfill_time, npts);
  409. timer("VFRAC     ", .220, .18, *vfrac_time, npts);
  410. timer("VFRACN    ", .230, .18, *vfracn_time, npts);
  411. for(i=0; i<npts; i++) ib[i] = i;
  412. timer("VGATHR    ", .19 , .16, *vgathr_time, npts);
  413. timer("VGEN      ", .075, .060,*vgen_time, npts);
  414. timer("VIADD     ", .097, .08, *viadd_time, npts);
  415. timer("VIAND     ", .230, .19, *viand_time, npts);
  416. timer("VIARS     ", .180, .14, *viars_time, npts);
  417. INIT_INPUTS (i)
  418. timer("VICLIP    ", .350, .27, *viclip_time, npts);
  419. timer("VILS      ", .180, .14, *vils_time, npts);
  420. timer("VIMAG     ", .095, .076,*vimag_time, npts);
  421. timer("VIMUL     ", .17 , .14, *vimul_time, npts);
  422. INIT_INPUTS (i+1)
  423. timer("VINDEX    ", .23 , .20, *vindex_time, npts);
  424. timer("VINEG     ", .080, .065,*vineg_time, npts);
  425. INIT_INPUTS (i)
  426. timer("VINTB     ", .099, .081,*vintb_time, npts);
  427. timer("VIOR      ", .23 , .19, *vior_time, npts);
  428. timer("VIRS      ", .180, .14, *virs_time, npts);
  429. timer("VISUB     ", .097, .08, *visub_time, npts);
  430. timer("VIXOR     ", .230, .19, *vixor_time, npts);
  431. timer("VLIM      ", .170, .14, *vlim_time, npts);
  432. INIT_INPUTS (i)
  433. timer("VLINT     ", .320, .250,*vlint_time, npts);
  434. timer("VLMERG    ", .21 , .17, *vlmerg_time, npts); 
  435. INIT_INPUTS (i+1)   // added +1 to prevent log 0 RDK
  436. timer("VLOG      ", .800, .64, *vlog_time, npts);
  437. timer("VLOG2     ", .800, .64, *vlog2_time, npts);
  438. timer("VLOG10    ", .800, .64, *vlog10_time, npts);
  439. timer("VMA       ", .13 , .11, *vma_time, npts);
  440. timer("VMAX      ", .18 , .14, *vmax_time, npts);
  441. timer("VMAXMG    ", .23 , .19, *vmaxmg_time, npts);
  442. timer("VMIN      ", .17 , .14, *vmin_time, npts);
  443. timer("VMINMG    ", .23 , .19, *vminmg_time, npts);
  444. timer("VMMA      ", .20 , .16, *vmma_time, npts);
  445. timer("VMMSB     ", .20 , .16, *vmmsb_time, npts);
  446. timer("VMOV      ", .068, .053,*vmov_time, npts);
  447. timer("VMSA      ", .098, .080,*vmsa_time, npts);
  448. timer("VMSB      ", .13 , .11, *vmsb_time, npts);
  449. timer("VMUL      ", .10 , .080,*vmul_time, npts);
  450. timer("VNABS     ", .120, .10, *vnabs_time, npts);
  451. timer("VNEG      ", .067, .053,*vneg_time, npts);
  452. timer("VNMSA     ", .098, .080,*vnmsa_time, npts);
  453. timer("VPMERG    ", .21 , .17, *vpmerg_time, npts);
  454. timer("VPOLY     ", .29 , .23, *vpoly_time, npts);
  455. timer("VQINT     ", .590, .480,*vqint_time, npts);
  456. timer("VRAMP     ", .071, .057,*vramp_time, npts);
  457. timer("VRAND     ", .320, .26, *vrand_time, npts);
  458. timer("VREAL     ", .096, .076,*vreal_time, npts);
  459. INIT_INPUTS (i+1)
  460. timer("VRECIP    ", .240, .190,*vrecip_time, npts);
  461. timer("VRSQRT    ", .310, .24, *vrsqrt_time, npts);
  462. timer("VRVRS     ", .067, .053, *vrvrs_time, npts);
  463. timer("VSADD     ", .067, .053,*vsadd_time, npts);
  464. timer("VSBM      ", .13 , .11, *vsbm_time, npts);
  465. timer("VSBSBM    ", .19 , .16, *vsbsbm_time, npts);
  466. timer("VSBSM     ", .10 , .081,*vsbsm_time, npts);
  467. INIT_INPUTS (i)
  468. timer("VSCATR    ", .19 , .15, *vscatr_time, npts);
  469. timer("VSDIV     ", .069, .054,*vsdiv_time, npts);
  470. timer("VSIMPS    ", .170, .14, *vsimps_time, npts);
  471. timer("VSIN      ", .780, .62, *vsin_time, npts);
  472. timer("VSINF     ", .620, .48, *vsinf_time, npts);
  473. timer("VSINRF    ", .240, .19, *vsinrf_time, npts);
  474. timer("VSM2SA    ", .100, .080,*vsm2sa_time, npts);
  475. timer("VSMA      ", .098, .080,*vsma_time, npts);
  476. timer("VSMA2     ", .099, .080,*vsma2_time, npts);
  477. timer("VSMA3     ", .130, .110,*vsma3_time, npts);
  478. timer("VSMA4     ", .160, .140,*vsma4_time, npts);
  479. timer("VSMSA     ", .068, .053,*vsmsa_time, npts);
  480. timer("VSMSB     ", .098,.080, *vsmsb_time, npts);
  481. timer("VSMUL     ", .068, .053,*vsmul_time, npts);
  482. timer("VSPDP     ", .099, .081, *vspdp_time, npts);
  483. timer("VSQ       ", .070, .053,*vsq_time, npts);
  484. INIT_INPUTS (2.0)
  485. timer("VSQRT     ", .320, .26, *vsqrt_time, npts); 
  486. timer("VSSQ      ", .130, .11, *vssq_time, npts);
  487. timer("VSUB      ", .099, .080,*vsub_time, npts);
  488. timer("VSUM      ", .110, .085,*vsum_time, npts);
  489. timer("VSWAP     ", .130, .10 ,*vswap_time, npts);
  490. timer("VTABI     ", .450, .36, *vtabi_time, npts);
  491. timer("VTAN      ", 1.80, 1.4, *vtan_time, npts);
  492. timer("VTANF     ", 1.10, .84, *vtanf_time, npts);
  493. timer("VTHR      ", .130, .10, *vthr_time, npts);
  494. timer("VTHRES    ", .200, .160,*vthres_time, npts);
  495. /*
  496. timer("VTMERG    ", .200, .16, *vtmerg_time, npts);
  497. */
  498. timer("VTRAPZ    ", .150, .12, *vtrapz_time, npts);
  499. timer("VXCS      ", 1.20, .92, *vxcs_time, npts);
  500. timer("VXCSF     ", 1.00, .83, *vxcsf_time, npts);
  501. INIT_INPUTS (.001*(i-300/2))
  502. timer("WIENER 100", 2.3, 3.0, *wiener_time, n100);
  503. timer("WIENER 300", 20.70, 27.0, *wiener_time, n300);
  504. printf("\nAll done.\n");fflush(stdout);
  505. }
  506.  
  507. /* below line added 12/10/98 RDK */
  508. void timer(char *name, float ptime2, float ptime3, void (*funct)(), long npt)
  509. /*
  510. timer(name, ptime2, ptime3, funct, npt)
  511. char *name;
  512. float ptime2, ptime3;
  513. void funct();
  514. long npt;
  515. */
  516. {
  517. #if MCOS
  518.     float ftime;
  519. #elif VXWORKS
  520.     ULONG    starttime;
  521.     ULONG    endtime;
  522. #else
  523.     clock_t    starttime;
  524.     clock_t    endtime;
  525. #endif
  526. //    clock_t    time1, time2;
  527. //    float    starttime;
  528. //    float    endtime;
  529.     double    overhead, elapsed, nanos;
  530.     float    psc2, psc3;
  531.     long i, iter, n1=1, npt1, ohpt=8;    /* ohpt=128; */
  532.     long esize, osize;
  533.  
  534. // printf("\nptime2=%f npt=%d\n",ptime2,npt);
  535.     esize = npt; osize = ohpt;
  536.     if (funct==(void(*)())&mxmov_time)
  537.         {
  538.         npt = (npt>512) ? 512 : npt;
  539.         esize = npt*npt; osize = ohpt*ohpt;
  540.         ptime2 *= (float)(esize)/(float)(n512*n512);
  541.         ptime3 *= (float)(esize)/(float)(n512*n512);
  542.         iter = 1000/ptime2;
  543.         }
  544.     else if ((funct==(void(*)())&mxmul_time) ||
  545.         (funct==(void(*)())&mxmla_time) ||
  546.         (funct==(void(*)())&mxmls_time))
  547.         {
  548.         npt = (npt>128) ? 128 : npt;
  549.         esize = npt*npt*npt; osize = ohpt*ohpt*ohpt;
  550.         ptime2 *= (float)(esize)/(float)(n128*n128*n128);
  551.         ptime3 *= (float)(esize)/(float)(n128*n128*n128);
  552.         iter = 10000/ptime2;          
  553.         }
  554.     else if ((funct!=(void(*)())&cfftf_time) &&
  555.         (funct!=(void(*)())&rfftf_time) &&
  556.         (funct!=(void(*)())&rffti_time) &&
  557.         (funct!=(void(*)())&wiener_time))
  558.         {
  559.         ptime2 *= (float)npt/(float)n1k;
  560.         ptime3 *= (float)npt/(float)n1k;
  561.         iter = 2000/ptime2;
  562.         }
  563.     else{
  564.         iter = 2000/ptime2;
  565.         }    
  566.     iter = (iter+31)&(-32);        /* keep #iters a multiple of 32    */
  567. #if TIME_FFT
  568. if (ptime2<.050) iter *= 100;
  569. else if (ptime2<.300) iter *= 25;
  570. #endif
  571.     if (iter<=0)
  572.         {
  573.         printf("ptime2=%f iter=%d!\n",ptime2,iter);
  574.         iter=32;
  575. /*        exit(0);    */
  576.         }
  577.     
  578. /*    Measure time for vector */
  579. #if MCOS
  580.     tmr_start_timesec();
  581.     funct(iter, npt);
  582.     tmr_get_timesec(&ftime);
  583.     elapsed = ftime*1000./iter; 
  584. #elif VXWORKS
  585.     starttime = tickGet();
  586.     funct(iter, npt);
  587.     endtime = tickGet();
  588.     elapsed = (float)(endtime-starttime)*1000./iter/(float)sysClkRateGet(); 
  589. #else
  590.     starttime = clock();
  591.     funct(iter, npt);
  592.      endtime = clock();
  593.     elapsed = (float)(endtime-starttime)*1000./iter/(float)CLOCKS_PER_SEC; 
  594. #endif
  595. //    time1 = clock();
  596. //    funct(iter, npt);
  597. //    time2 = clock();
  598. //    starttime = time1*(1000./CLOCKS_PER_SEC);
  599. //    endtime = time2*(1000./CLOCKS_PER_SEC);
  600. //    elapsed = (endtime-starttime)/iter; 
  601.  
  602. /*    Measure overhead by timing n/64 (16) point and solving equation */
  603.  
  604.     iter = iter*npt/ohpt;
  605. #if MCOS
  606.     tmr_start_timesec();
  607.     funct(iter, ohpt);
  608.     tmr_get_timesec(&ftime);
  609.     overhead = ftime*1000./iter; 
  610. #elif VXWORKS
  611.     starttime = tickGet();
  612.     funct(iter, ohpt);
  613.     endtime = tickGet();
  614.     overhead = (float)(endtime-starttime)*1000./iter/(float)sysClkRateGet();
  615. #else
  616.     starttime = clock();
  617.     funct(iter, ohpt);
  618.     endtime = clock();
  619.     overhead = (double)(endtime-starttime)*1000.0/iter/(double)CLOCKS_PER_SEC;
  620. #endif
  621. //    time1 = clock();
  622. //    funct(iter, ohpt);
  623. //    time2 = clock();
  624. //    starttime = time1*(1000./CLOCKS_PER_SEC);
  625. //    endtime = time2*(1000./CLOCKS_PER_SEC);
  626. //    overhead = (endtime-starttime)/iter;
  627. // printf("iter=%d elapsed=%e npt=%d overhead=%e ohpt=%d\n",iter,elapsed,npt,overhead,ohpt);
  628.     overhead = (elapsed-esize*overhead/osize)/(1.0-(double)esize/osize);
  629.    /* added 12/10/98 RDK */
  630.    if (overhead<0.0) overhead=0.0;
  631.     nanos = (elapsed - overhead)/esize *1000000;
  632.     overhead = overhead*1000;
  633.     psc2 = ptime2/elapsed*100;
  634.     psc3 = ptime3/elapsed*100;
  635.     printf("\n%s%6.3f   %6.3f   %6.3f %6.1f    %6.1f   %6.1f   %6.1f",
  636.         name, ptime2, ptime3, elapsed, overhead, nanos, psc2, psc3);
  637. }
  638.